﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Common;
using System.Web.Script.Serialization;
using Basic.VO;
using Basic.Business;

public partial class Basic_Background_RoleGroupManage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //强制刷新页面
        Response.Buffer = true;
        Response.ExpiresAbsolute = System.DateTime.Now.AddSeconds(-1);
        Response.Expires = 0;
        Response.CacheControl = "no-cache";
        Response.AppendHeader("Pragma", "No-Cache");
        //判断用户是否登录
        if (!Tools.IsAdminSessionValid())
        {
            Tools.ShowInfo(StringTable.ErrorSessionTimeOut, "../Background/AdminLogin.aspx", "_self");
        }

        //处理AJAX
        if (!String.IsNullOrEmpty(Request.QueryString["Action"]))
        {
            Result<RoleGroup> result = new Result<RoleGroup>();
            JavaScriptSerializer json = new JavaScriptSerializer();
            string action = BadChar.ReplaceBadChar(Request.QueryString["Action"]);
            switch (action)
            {
                case "search":
                    try
                    {
                        if (!RoleAdmin.CheckRole("系统用户组管理", (Basic.VO.Admin)Session["admin"]))
                            throw new Exception("你没有这个权限");
                        result = RoleGroupAdmin.GetAllByCondition(-1, -1);
                        result.error = false;
                        result.msg = "获取系统用户列表成功！";
                    }
                    catch (Exception ex)
                    {
                        result.error = true;
                        result.msg = ex.Message;
                    }
                    break;
                default:
                    result.error = true;
                    result.msg = StringTable.ErrorUnknowAction;
                    break;
            }
            Response.Write(json.Serialize(result));
            Response.End();
        }
    }
}
